{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pixel_filter_util\n",
    "import cooler"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- cis_total_ratio_filter() allows partial evaluation. However if you only provide threshold, you will need to use key word 'threshold' as the below example. This will return a function that can further take cooler object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_filter = pixel_filter_util.cis_total_ratio_filter(threshold=0.5)\n",
    "clr = cooler.Cooler('test_data_util.cool')\n",
    "bin_mask = test_filter(clr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- If you have multiple filters you can use generate_bin_mask() to apply filters sequentially to the bin table and output a mask"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_filter2 = pixel_filter_util.cis_total_ratio_filter(threshold=0.7)\n",
    "bin_mask = pixel_filter_util.generate_bin_mask(clr, [test_filter, test_filter2])\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- The bin_mask then can be used in create_filtered_cooler"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "output_path = f\"./test_data_util_filtered.cool\"\n",
    "pixel_filter_util.create_filtered_cooler(\n",
    "            output_path, clr, bin_mask, chunksize=10_000_000, nproc=1\n",
    "        )"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "akita",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
